package com.cskaoyan.controller.admin;


import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.admin.Configuration.*;
import com.cskaoyan.service.admin.ConfigService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("admin/config")
public class ConfigController {

    @Autowired
    ConfigService configService;

    //向磊 admin/config/mall (get请求)
    @RequiresPermissions(value = {"*", "admin:config:mall"}, logical = Logical.OR)
    @GetMapping("mall")
    public BaseRespVo mall(){
        ConfigMallVo data = configService.mall();
        return BaseRespVo.ok(data);
    }
    //向磊 admin/config/mall (post请求)
    @RequiresPermissions(value = {"*", "admin:config:mall"}, logical = Logical.OR)
    @PostMapping("mall")
    public BaseRespVo mall2(@RequestBody ConfigMallBo configMallBo){
        configService.UpdateMall(configMallBo);
        return BaseRespVo.ok();
    }



    //向磊 admin/config/express (get请求)
    @RequiresPermissions(value = {"*", "admin:config:express"}, logical = Logical.OR)
    @GetMapping("express")
    public BaseRespVo configExpress(){
        ConfigExpressVo data = configService.configExpress();
        return BaseRespVo.ok(data);
    }
    //向磊 admin/config/express (post请求)
    @RequiresPermissions(value = {"*", "admin:config:express"}, logical = Logical.OR)
    @PostMapping("express")
    public BaseRespVo configExpress2(@RequestBody ConfigExpressBo configExpressBo){
        configService.updateExpress(configExpressBo);
        return BaseRespVo.ok();
    }



    //向磊 admin/config/order (get请求)
    @GetMapping("order")
    public BaseRespVo configOrder(){
        ConfigOrderVo data = configService.configOrder();
        return BaseRespVo.ok(data);
    }
    //向磊 admin/config/order (post请求)
    @RequiresPermissions("admin:config:order")
    @PostMapping("order")
    public BaseRespVo configOrder2(@RequestBody ConfigOrderBo configOrderBo){
        configService.updateOrder(configOrderBo);
        return BaseRespVo.ok();
    }



    //向磊 admin/config/wx (get请求)
    @RequiresPermissions("admin:config:wx")
    @GetMapping("wx")
    public BaseRespVo configWx(){
        ConfigWxVo data = configService.configWx();
        return BaseRespVo.ok(data);
    }
    //向磊 admin/config/wx (post请求)
    @RequiresPermissions("admin:config:wx")
    @PostMapping("wx")
    public BaseRespVo configWx2(@RequestBody ConfigWxBo configWxBo){
        configService.updateWx(configWxBo);
        return BaseRespVo.ok();
    }


}
